package com.ruoyi.manage.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.manage.mapper.SurgeryWorkerMapper;
import com.ruoyi.manage.domain.SurgeryWorker;
import com.ruoyi.manage.service.ISurgeryWorkerService;

/**
 * 手术参与人员Service业务层处理
 * 
 * @author liuyangyang
 * @date 2025-06-08
 */
@Service
public class SurgeryWorkerServiceImpl implements ISurgeryWorkerService 
{
    @Autowired
    private SurgeryWorkerMapper surgeryWorkerMapper;

    /**
     * 查询手术参与人员
     * 
     * @param surgeryWorkerId 手术参与人员主键
     * @return 手术参与人员
     */
    @Override
    public SurgeryWorker selectSurgeryWorkerBySurgeryWorkerId(Long surgeryWorkerId)
    {
        return surgeryWorkerMapper.selectSurgeryWorkerBySurgeryWorkerId(surgeryWorkerId);
    }

    /**
     * 查询手术参与人员列表
     * 
     * @param surgeryWorker 手术参与人员
     * @return 手术参与人员
     */
    @Override
    public List<SurgeryWorker> selectSurgeryWorkerList(SurgeryWorker surgeryWorker)
    {
        return surgeryWorkerMapper.selectSurgeryWorkerList(surgeryWorker);
    }

    /**
     * 新增手术参与人员
     * 
     * @param surgeryWorkers 手术参与人员
     * @return 结果
     */
    @Override
    public void insertSurgeryWorker(List<SurgeryWorker> surgeryWorkers)
    {
        surgeryWorkers.forEach(surgeryWorker -> {
            if (surgeryWorker.getSurgeryWorkerId() != null) {
                surgeryWorkerMapper.updateSurgeryWorker(surgeryWorker);
            }else{
                surgeryWorker.setCreateTime(DateUtils.getNowDate());
                surgeryWorkerMapper.insertSurgeryWorker(surgeryWorker);
            }

        });
    }

    /**
     * 修改手术参与人员
     * 
     * @param surgeryWorker 手术参与人员
     * @return 结果
     */
    @Override
    public int updateSurgeryWorker(SurgeryWorker surgeryWorker)
    {
        surgeryWorker.setUpdateTime(DateUtils.getNowDate());
        return surgeryWorkerMapper.updateSurgeryWorker(surgeryWorker);
    }

    /**
     * 批量删除手术参与人员
     * 
     * @param surgeryWorkerIds 需要删除的手术参与人员主键
     * @return 结果
     */
    @Override
    public int deleteSurgeryWorkerBySurgeryWorkerIds(Long[] surgeryWorkerIds)
    {
        return surgeryWorkerMapper.deleteSurgeryWorkerBySurgeryWorkerIds(surgeryWorkerIds);
    }

    /**
     * 删除手术参与人员信息
     * 
     * @param surgeryWorkerId 手术参与人员主键
     * @return 结果
     */
    @Override
    public int deleteSurgeryWorkerBySurgeryWorkerId(Long surgeryWorkerId)
    {
        return surgeryWorkerMapper.deleteSurgeryWorkerBySurgeryWorkerId(surgeryWorkerId);
    }
}
